<?php
class my_ads extends CI_Model {



    function get_ads($tot_num, $offset,$email)
    {        
        $this->db->where('user_id',$this->session->userdata('user_id'));
        $query = $this->db->get('ads', $tot_num, $offset);
        return $query->result();
        
    }	
    
    function get_edit_ad_record($id)
    {
       
    	$this->db->where('ad_id',$id);
        $query = $this->db->get('ads');
        return $query->result();
        
    }	
    
    function update_ad_record($data,$ad_id)
    {
       
    	$this->db->where('ad_id',$ad_id);
        $this->db->update('ads',$data);
        
    }	
    
    function delete_ad_record($ad_id)
    {
       
    	$this->db->where('ad_id',$ad_id);
        $this->db->delete('ads'); 
        
    }	
    
        
    function deactive_ad_record($ad_id,$data)
    {
       
    	$this->db->where('ad_id',$ad_id);
        $this->db->update('ads',$data);
        
    }	
      function active_ad_record($ad_id,$data)
    {
       
    	$this->db->where('ad_id',$ad_id);
        $this->db->update('ads',$data);
        
    }	
    
 function image_path_to_delete($ad_id,$img_id)
    {
       
     $this->db->select($img_id); 
     $this->db->from('ads');   
     $this->db->where('ad_id',$ad_id);
     $result = $this->db->get();
     foreach ($result->result_array() as $row)
     {
         return $row[$img_id];
     }
    }	

}